<template>
	<view v-if="item" class="cu-card article no-card padding-top-sm" @tap.stop="goDetail(item.id)">
		<view class="cu-item shadow">
			<view class="title">
				<view class="text-cut">{{ item.title }}</view>
			</view>
			<view class="content">
				<image :src="getImg(item.coverImage)" mode="aspectFill"></image>
				<view class="desc">
					<view class="text-content">{{ item.content }}</view>
					<view>
						<view class="cu-tag bg-red light sm round" @tap.stop="goArchive(0, item.categoryName, item.categoryId)">{{ item.categoryName }}</view>
						<view class="cu-tag bg-green light sm round" v-for="(item, index) in item.label" :key="index" @tap="goArchive(2, item.name, item.id)">{{ item.name }}</view>
					</view>
				</view>
			</view>
			<view class="flex padding-left-sm padding-right-sm padding-top-sm justify-between">
				<view class="text-gray text-df">{{ formatDate(item.updateTime) }}</view>
				<view class="text-gray text-sm text-right padding-right-sm">
					<text class="cuIcon-attentionfill margin-lr-xs"></text> {{ item.readNum }}
					<text class="cuIcon-appreciatefill margin-lr-xs"></text> {{ item.likeNum }}
					<text class="cuIcon-messagefill margin-lr-xs"></text> {{ item.commentNum }}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			item :{
				type: Object,
				default: null
			},
			jump: {
				type: Boolean,
				default: true
			}
		},
		data() {
			return {
				
			};
		},
		methods: {
			getImg(img) {
				return this.$tools.getImg(img, '/static/default.png')
			},
			formatDate(date) {
				return this.$tools.formatDate(date)
			},
			goDetail(id) {
				this.$tools.go('/pages/article/detail?id=' + id)
			},
			goArchive(type, title, key) {
				if (this.jump) {
					this.$tools.go('/pages/archive/detail?type=' + type + '&title=' + title + '&key=' + key)
				}
			}
		}
	}
</script>

<style>

</style>
